#include<bits/stdc++.h>
using namespace std;
int n,m,V,l;
int v0[100000],record[100000],a[100000],d[1000000],p[1000000];
float v[100000];
bool te[100000];
int main(){
freopen("detect.in","r",stdin);
freopen("detect.ans","w",stdout);
int t;
scanf("%d",&t);
while(t--){
int ans,num;
cin>>n>>m>>l>>V;
for(int i=1;i<=n;i++){
cin>>v[i]>>a[i]>>d[i];
}
for(int j=1;j<=m;j++){
cin>>p[j];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
v[j]=sqrt(v[i]*v[i]+2*a[i]*p[j]);
if(p[j]>(float)V){
te[i]=0;
ans++;
record[j]=1;
break;
}
}
}
for(int i=1;i<=m;i++){
if(record[i]) num++;
}
cout<<ans<<" "<<num;
}
return 0;
}
